{
  "name": "Case 83 - Academic Researcher - Thought Leadership Tracker",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 9 * * 1"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -1040,
        -144
      ],
      "id": "e0885daf-b3a3-4671-9ecc-5646c16b5ac5",
      "name": "Weekly Schedule - Monday 9 AM"
    },
    {
      "parameters": {
        "actorId": {
          "__rl": true,
          "value": "buIWk2uOUzTmcLsuB",
          "mode": "list",
          "cachedResultName": "Linkedin Post Search Scraper (No Cookies) (harvestapi/linkedin-post-search)",
          "cachedResultUrl": "https://console.apify.com/actors/buIWk2uOUzTmcLsuB/input"
        },
        "customBody": "{\n  \"authorUrls\": [\n    \"https://www.linkedin.com/school/stanford-university\",\n    \"https://www.linkedin.com/school/massachusetts-institute-of-technology\",\n    \"https://www.linkedin.com/school/harvard-university\",\n    \"https://www.linkedin.com/school/university-of-california-berkeley\",\n    \"https://www.linkedin.com/school/university-of-oxford\",\n    \"https://www.linkedin.com/school/university-of-cambridge\"\n  ],\n  \"searchQueries\": [\n    \"research\",\n    \"published\",\n    \"paper\",\n    \"findings\",\n    \"conference\",\n    \"study\"\n  ],\n  \"maxPosts\": 50,\n  \"scrapeComments\": false,\n  \"scrapeReactions\": false\n}"
      },
      "type": "@apify/n8n-nodes-apify.apify",
      "typeVersion": 1,
      "position": [
        -864,
        -144
      ],
      "id": "fbdd054c-2f86-4120-b762-c79913013fae",
      "name": "Scrape LinkedIn Research Posts",
      "credentials": {
        "apifyApi": {
          "id": "w5S6YBbbyUddEfQA",
          "name": "Apify account"
        }
      }
    },
    {
      "parameters": {
        "resource": "Datasets",
        "datasetId": "={{ $json.defaultDatasetId }}"
      },
      "type": "@apify/n8n-nodes-apify.apify",
      "typeVersion": 1,
      "position": [
        -688,
        -144
      ],
      "id": "b2f1fbd5-f946-4c27-bccb-75eaeecdfdf2",
      "name": "Get Dataset Items",
      "credentials": {
        "apifyApi": {
          "id": "w5S6YBbbyUddEfQA",
          "name": "Apify account"
        }
      }
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4o-mini"
        },
        "responses": {
          "values": [
            {
              "role": "system",
              "content": "=You are an Academic Thought Leadership Validation Expert.\n\nAnalyze LinkedIn posts to determine if they are genuine academic thought leadership content.\n\nReturn ONLY valid JSON in this exact format:\n{\n  \"is_thought_leadership\": \"yes|no\",\n  \"confidence\": 0.95,\n  \"reason\": \"brief explanation\"\n}\n\nCriteria for \"yes\" (genuine thought leadership):\n✅ Shares original research findings or publications\n✅ Presents conference paper or keynote insights\n✅ Offers expert analysis on emerging trends/topics\n✅ Discusses research methodology or innovations\n✅ Announces research collaborations or grants\n✅ Reviews or critiques existing literature\n✅ Proposes new theoretical frameworks\n✅ Shares data-driven insights from studies\n✅ Discusses academic partnerships or initiatives\n\nCriteria for \"no\" (NOT thought leadership):\n❌ Personal opinions without research backing\n❌ Promotional content for courses/programs\n❌ Student achievement announcements\n❌ Administrative or event logistics posts\n❌ Casual sharing of others' content without analysis\n❌ Job postings or hiring announcements\n❌ Generic inspirational quotes or advice\n❌ Social/networking events without research focus\n\nRules:\n1. confidence: 0-1 scale (0.9+ for very clear thought leadership)\n2. reason: 1 sentence explaining the decision\n3. Be strict - require substantive academic/research content\n4. Return ONLY the JSON object, no explanations"
            },
            {
              "content": "=Analyze this LinkedIn post to determine if it's genuine thought leadership:\n\nAuthor: {{ $json.author.name }}\nAuthor Info: {{ $json.author.info }}\nPost Date: {{ $json.postedAt.date }}\nPost Content: {{ $json.content }}\n\nReturn only JSON."
            }
          ]
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.1,
      "position": [
        -528,
        -144
      ],
      "id": "9353271d-8dd7-497e-a68c-79c16cb25d76",
      "name": "AI Validation Filter",
      "credentials": {
        "openAiApi": {
          "id": "ICwxUBbatsF2sDvy",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// UNIVERSAL AI RESPONSE PARSER - Same code for ALL cases\nconst items = [];\nconst input = $input.all();\n\nfunction extractJSON(text) {\n  const jsonMatch = text.match(/\\{[\\s\\S]*\\}/);\n  if (!jsonMatch) return null;\n  return jsonMatch[0];\n}\n\ninput.forEach((item, index) => {\n  try {\n    let aiText = item.json.output[0].content[0].text || '';\n    \n    // Clean markdown code blocks\n    aiText = aiText\n      .replace(/```json/gi, '')\n      .replace(/```/g, '')\n      .trim();\n    \n    // Extract JSON object\n    const jsonStr = extractJSON(aiText);\n    \n    if (!jsonStr) {\n      throw new Error('No JSON found in AI response');\n    }\n    \n    // Parse and return clean JSON\n    const parsed = JSON.parse(jsonStr);\n    items.push({ json: parsed });\n    \n  } catch (error) {\n    console.error(`Parse error for item ${index}:`, error.message);\n    // Return empty object on error - no case-specific fields\n    items.push({ json: {} });\n  }\n});\n\nreturn items;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -256,
        -144
      ],
      "id": "c313c32f-fb25-4d49-a0a3-2cf831605856",
      "name": "Parse AI Validation"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "is_thought_leadership",
              "name": "is_thought_leadership",
              "value": "={{ $json.is_thought_leadership }}",
              "type": "string"
            },
            {
              "id": "confidence",
              "name": "confidence",
              "value": "={{ $json.confidence }}",
              "type": "number"
            },
            {
              "id": "reason",
              "name": "reason",
              "value": "={{ $json.reason }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -80,
        -144
      ],
      "id": "73f1d7c8-ae7e-42ac-a214-e9a90508a96f",
      "name": "Edit Fields - Validation"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "condition-001",
              "leftValue": "={{ $json.is_thought_leadership }}",
              "rightValue": "yes",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2,
      "position": [
        96,
        -144
      ],
      "id": "47bf9f24-2541-47ce-bfaf-935407466b13",
      "name": "Filter Only Thought Leadership"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4o-mini"
        },
        "responses": {
          "values": [
            {
              "role": "system",
              "content": "=You are an Academic Research Intelligence Analyst.\n\nExtract structured thought leadership information from LinkedIn posts.\n\nReturn ONLY valid JSON in this exact format:\n{\n  \"researcher_name\": \"Name of researcher/author\",\n  \"institution\": \"University/Research center affiliation\",\n  \"research_area\": \"Field/topic of research (e.g., 'Machine Learning', 'Climate Science')\",\n  \"content_type\": \"Paper|Conference|Opinion|Partnership|Funding|Review|Dataset|Framework\",\n  \"key_insight\": \"Main finding or contribution in 150 chars or less\",\n  \"methodology\": \"Research method if mentioned (Experimental|Survey|Meta-analysis|Theoretical|Computational|Other)\",\n  \"collaboration_potential\": \"Yes|No - does this indicate openness to collaboration?\",\n  \"citation_worthy\": \"Yes|No - is this significant enough to cite?\",\n  \"relevance_score\": \"High|Medium|Low - relevance to AI/ML field\",\n  \"publication_venue\": \"Journal/Conference name if mentioned, otherwise 'Not specified'\"\n}\n\nExtraction Rules:\n1. researcher_name: Extract from author info\n2. institution: Extract university/organization affiliation\n3. research_area: Identify specific research domain\n4. content_type:\n   - Paper = Published research paper\n   - Conference = Conference presentation/proceedings\n   - Opinion = Expert commentary/perspective\n   - Partnership = Research collaboration announcement\n   - Funding = Grant or funding announcement\n   - Review = Literature review or critique\n   - Dataset = New dataset release\n   - Framework = New theoretical framework\n5. key_insight: Summarize main contribution briefly\n6. methodology: Extract research method used\n7. collaboration_potential:\n   - Yes = Mentions seeking collaborators, open research, or partnerships\n   - No = Standalone announcement\n8. citation_worthy:\n   - Yes = Novel finding, significant result, or major contribution\n   - No = Incremental or preliminary work\n9. relevance_score: Assess relevance to AI/ML (adjust field as needed)\n10. publication_venue: Extract journal/conference name\n\nReturn ONLY the JSON object, no explanations."
            },
            {
              "content": "=Extract thought leadership intelligence from this LinkedIn post:\n\nAuthor: {{ $('Get Dataset Items').item.json.author.name }}\nAuthor Info: {{ $('Get Dataset Items').item.json.author.info }}\nPost Date: {{ $('Get Dataset Items').item.json.postedAt.date }}\nPost Content: {{ $('Get Dataset Items').item.json.content }}\nEngagement: {{ $('Get Dataset Items').item.json.engagement.likes }} likes, {{ $('Get Dataset Items').item.json.engagement.comments }} comments\n\nReturn only JSON."
            }
          ]
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.1,
      "position": [
        256,
        -144
      ],
      "id": "c032171f-2492-4835-b320-f106fa787d9d",
      "name": "AI Extract Research Intelligence",
      "credentials": {
        "openAiApi": {
          "id": "ICwxUBbatsF2sDvy",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// UNIVERSAL AI RESPONSE PARSER - Same code for ALL cases\nconst items = [];\nconst input = $input.all();\n\nfunction extractJSON(text) {\n  const jsonMatch = text.match(/\\{[\\s\\S]*\\}/);\n  if (!jsonMatch) return null;\n  return jsonMatch[0];\n}\n\ninput.forEach((item, index) => {\n  try {\n    let aiText = item.json.output[0].content[0].text || '';\n    \n    // Clean markdown code blocks\n    aiText = aiText\n      .replace(/```json/gi, '')\n      .replace(/```/g, '')\n      .trim();\n    \n    // Extract JSON object\n    const jsonStr = extractJSON(aiText);\n    \n    if (!jsonStr) {\n      throw new Error('No JSON found in AI response');\n    }\n    \n    // Parse and return clean JSON\n    const parsed = JSON.parse(jsonStr);\n    items.push({ json: parsed });\n    \n  } catch (error) {\n    console.error(`Parse error for item ${index}:`, error.message);\n    // Return empty object on error - no case-specific fields\n    items.push({ json: {} });\n  }\n});\n\nreturn items;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        528,
        -144
      ],
      "id": "de68ad33-62a6-4c9a-9f8d-2339599acf36",
      "name": "Parse AI Response"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "timestamp",
              "name": "analysis_timestamp",
              "value": "={{ new Date().toISOString() }}",
              "type": "string"
            },
            {
              "id": "researcher_name",
              "name": "researcher_name",
              "value": "={{ $json.researcher_name }}",
              "type": "string"
            },
            {
              "id": "institution",
              "name": "institution",
              "value": "={{ $json.institution }}",
              "type": "string"
            },
            {
              "id": "research_area",
              "name": "research_area",
              "value": "={{ $json.research_area }}",
              "type": "string"
            },
            {
              "id": "content_type",
              "name": "content_type",
              "value": "={{ $json.content_type }}",
              "type": "string"
            },
            {
              "id": "key_insight",
              "name": "key_insight",
              "value": "={{ $json.key_insight }}",
              "type": "string"
            },
            {
              "id": "methodology",
              "name": "methodology",
              "value": "={{ $json.methodology }}",
              "type": "string"
            },
            {
              "id": "collaboration",
              "name": "collaboration_potential",
              "value": "={{ $json.collaboration_potential }}",
              "type": "string"
            },
            {
              "id": "citation",
              "name": "citation_worthy",
              "value": "={{ $json.citation_worthy }}",
              "type": "string"
            },
            {
              "id": "relevance",
              "name": "relevance_score",
              "value": "={{ $json.relevance_score }}",
              "type": "string"
            },
            {
              "id": "publication",
              "name": "publication_venue",
              "value": "={{ $json.publication_venue }}",
              "type": "string"
            },
            {
              "id": "author_profile",
              "name": "author_profile",
              "value": "={{ $('Get Dataset Items').item.json.author?.linkedinUrl || '' }}",
              "type": "string"
            },
            {
              "id": "author_info",
              "name": "author_info",
              "value": "={{ $('Get Dataset Items').item.json.author?.info || '' }}",
              "type": "string"
            },
            {
              "id": "post_content",
              "name": "post_content",
              "value": "={{ $('Get Dataset Items').item.json.content || '' }}",
              "type": "string"
            },
            {
              "id": "post_date",
              "name": "post_date",
              "value": "={{ $('Get Dataset Items').item.json.postedAt?.date || '' }}",
              "type": "string"
            },
            {
              "id": "post_url",
              "name": "post_url",
              "value": "={{ $('Get Dataset Items').item.json.linkedinUrl || '' }}",
              "type": "string"
            },
            {
              "id": "likes",
              "name": "likes_count",
              "value": "={{ $('Get Dataset Items').item.json.engagement?.likes || 0 }}",
              "type": "number"
            },
            {
              "id": "comments",
              "name": "comments_count",
              "value": "={{ $('Get Dataset Items').item.json.engagement?.comments || 0 }}",
              "type": "number"
            },
            {
              "id": "shares",
              "name": "shares_count",
              "value": "={{ $('Get Dataset Items').item.json.engagement?.shares || 0 }}",
              "type": "number"
            },
            {
              "id": "total_engagement",
              "name": "engagement_total",
              "value": "={{ ($('Get Dataset Items').item.json.engagement?.likes || 0) + ($('Get Dataset Items').item.json.engagement?.comments || 0) + ($('Get Dataset Items').item.json.engagement?.shares || 0) }}",
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        688,
        -144
      ],
      "id": "71370b45-e67c-43db-ad8f-b51d096cbce0",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1tzpeRbCgcOJzZj-sORBbZaCuXZjE2A7cLvcEuuouM3Q",
          "mode": "list",
          "cachedResultName": "Case 83 - Academic Researcher Log",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1tzpeRbCgcOJzZj-sORBbZaCuXZjE2A7cLvcEuuouM3Q/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1tzpeRbCgcOJzZj-sORBbZaCuXZjE2A7cLvcEuuouM3Q/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Analysis_Date": "={{ $json.analysis_timestamp }}",
            "Researcher_Name": "={{ $json.researcher_name }}",
            "Institution": "={{ $json.institution }}",
            "Research_Area": "={{ $json.research_area }}",
            "Content_Type": "={{ $json.content_type }}",
            "Key_Insight": "={{ $json.key_insight }}",
            "Methodology": "={{ $json.methodology }}",
            "Collaboration_Potential": "={{ $json.collaboration_potential }}",
            "Citation_Worthy": "={{ $json.citation_worthy }}",
            "Relevance_Score": "={{ $json.relevance_score }}",
            "Publication_Venue": "={{ $json.publication_venue }}",
            "Author_Profile": "={{ $json.author_profile }}",
            "Post_Date": "={{ $json.post_date }}",
            "Likes": "={{ $json.likes_count }}",
            "Comments": "={{ $json.comments_count }}",
            "Shares": "={{ $json.shares_count }}",
            "Total_Engagement": "={{ $json.engagement_total }}",
            "Post_URL": "={{ $json.post_url }}",
            "Post_Content": "={{ $json.post_content }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Analysis_Date",
              "displayName": "Analysis_Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Researcher_Name",
              "displayName": "Researcher_Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Institution",
              "displayName": "Institution",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Research_Area",
              "displayName": "Research_Area",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Content_Type",
              "displayName": "Content_Type",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Key_Insight",
              "displayName": "Key_Insight",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Methodology",
              "displayName": "Methodology",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Collaboration_Potential",
              "displayName": "Collaboration_Potential",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Citation_Worthy",
              "displayName": "Citation_Worthy",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Relevance_Score",
              "displayName": "Relevance_Score",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Publication_Venue",
              "displayName": "Publication_Venue",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Author_Profile",
              "displayName": "Author_Profile",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Post_Date",
              "displayName": "Post_Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Likes",
              "displayName": "Likes",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Comments",
              "displayName": "Comments",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Shares",
              "displayName": "Shares",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Total_Engagement",
              "displayName": "Total_Engagement",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Post_URL",
              "displayName": "Post_URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Post_Content",
              "displayName": "Post_Content",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        848,
        -144
      ],
      "id": "466d60e9-b86a-4a74-a490-4e38c339e4bd",
      "name": "Log to Google Sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "LOs2dbk9lby0NfDM",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Aggregate all items from Google Sheets into email-ready summary\nconst allItems = $input.all();\n\n// Count by research area\nconst areaCounts = {};\nallItems.forEach(item => {\n  const area = item.json.Research_Area || 'Other';\n  areaCounts[area] = (areaCounts[area] || 0) + 1;\n});\n\nconst topAreas = Object.entries(areaCounts)\n  .sort((a, b) => b[1] - a[1])\n  .slice(0, 10);\n\n// Count by content type\nconst contentTypeCounts = {};\nallItems.forEach(item => {\n  const type = item.json.Content_Type || 'Other';\n  contentTypeCounts[type] = (contentTypeCounts[type] || 0) + 1;\n});\n\n// Count by institution\nconst institutionCounts = {};\nallItems.forEach(item => {\n  const institution = item.json.Institution || 'Unknown';\n  institutionCounts[institution] = (institutionCounts[institution] || 0) + 1;\n});\n\nconst topInstitutions = Object.entries(institutionCounts)\n  .sort((a, b) => b[1] - a[1])\n  .slice(0, 10);\n\n// Citation-worthy research\nconst citationWorthy = allItems.filter(item => \n  item.json.Citation_Worthy === 'Yes'\n);\n\n// Collaboration opportunities\nconst collaborationOps = allItems.filter(item => \n  item.json.Collaboration_Potential === 'Yes'\n);\n\n// High relevance research\nconst highRelevance = allItems.filter(item => \n  item.json.Relevance_Score === 'High'\n);\n\n// Count by methodology\nconst methodCounts = {};\nallItems.forEach(item => {\n  const method = item.json.Methodology || 'Other';\n  methodCounts[method] = (methodCounts[method] || 0) + 1;\n});\n\n// Build HTML table rows\nconst tableRows = allItems.map(item => {\n  const data = item.json;\n  const relevanceColor = data.Relevance_Score === 'High' ? '#28a745' : \n                         data.Relevance_Score === 'Medium' ? '#ffc107' : '#6c757d';\n  \n  return `\n    <tr>\n      <td>${data.Researcher_Name || 'N/A'}</td>\n      <td>${data.Institution || 'N/A'}</td>\n      <td>${data.Research_Area || 'N/A'}</td>\n      <td>${data.Content_Type || 'N/A'}</td>\n      <td><span style=\"color: ${relevanceColor}; font-weight: bold;\">${data.Relevance_Score || 'N/A'}</span></td>\n      <td>${data.Citation_Worthy || 'N/A'}</td>\n      <td><a href=\"${data.Post_URL || '#'}\">View</a></td>\n    </tr>\n  `;\n}).join('');\n\n// Return single aggregated item\nreturn {\n  json: {\n    week_start: new Date(Date.now() - 7*24*60*60*1000).toISOString().split('T')[0],\n    week_end: new Date().toISOString().split('T')[0],\n    total_posts: allItems.length,\n    top_research_areas: topAreas,\n    content_type_breakdown: Object.entries(contentTypeCounts),\n    top_institutions: topInstitutions,\n    citation_worthy_count: citationWorthy.length,\n    collaboration_opportunities_count: collaborationOps.length,\n    high_relevance_count: highRelevance.length,\n    methodology_breakdown: Object.entries(methodCounts),\n    table_rows: tableRows,\n    all_research: allItems.map(item => item.json)\n  }\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1024,
        -144
      ],
      "id": "36727dd8-ef8e-487b-9b0e-8860b2260991",
      "name": "Aggregate Weekly Summary"
    },
    {
      "parameters": {
        "sendTo": "researcher@university.edu",
        "subject": "=📊 Weekly Thought Leadership Report: {{ $json.week_start }} to {{ $json.week_end }}",
        "message": "=WEEKLY THOUGHT LEADERSHIP INTELLIGENCE REPORT\n================================================\nReport Period: {{ $json.week_start }} to {{ $json.week_end }}\n\nOVERVIEW:\nTotal Research Posts Tracked: {{ $json.total_posts }}\nCitation-Worthy Research: {{ $json.citation_worthy_count }}\nCollaboration Opportunities: {{ $json.collaboration_opportunities_count }}\nHigh Relevance Posts: {{ $json.high_relevance_count }}\n\nTOP RESEARCH AREAS:\n{{ $json.top_research_areas.map(([area, count], i) => (i+1) + '. ' + area + ' (' + count + ' posts)').join('\\n') }}\n\nCONTENT TYPE BREAKDOWN:\n{{ $json.content_type_breakdown.map(([type, count]) => type + ': ' + count).join('\\n') }}\n\nTOP INSTITUTIONS:\n{{ $json.top_institutions.map(([inst, count], i) => (i+1) + '. ' + inst + ' (' + count + ' posts)').join('\\n') }}\n\nMETHODOLOGY DISTRIBUTION:\n{{ $json.methodology_breakdown.map(([method, count]) => method + ': ' + count).join('\\n') }}\n\n🎯 ACTION ITEMS:\n📚 {{ $json.citation_worthy_count }} citation-worthy papers to review\n🤝 {{ $json.collaboration_opportunities_count }} collaboration opportunities to explore\n⭐ {{ $json.high_relevance_count }} highly relevant posts to your field\n\nFull thought leadership details in Google Sheets.\n\nGenerated: {{ new Date().toLocaleDateString() }}",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1200,
        -144
      ],
      "id": "9e917f22-2062-4a5c-aab3-f2d951f65f85",
      "name": "Send Weekly Summary Email",
      "webhookId": "08ffa92c-adb0-4f91-90ce-dc0902dd03b4",
      "credentials": {
        "gmailOAuth2": {
          "id": "cyqCGWcggZNMcSOv",
          "name": "Gmail account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Weekly Schedule - Monday 9 AM": {
      "main": [
        [
          {
            "node": "Scrape LinkedIn Research Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape LinkedIn Research Posts": {
      "main": [
        [
          {
            "node": "Get Dataset Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Dataset Items": {
      "main": [
        [
          {
            "node": "AI Validation Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Validation Filter": {
      "main": [
        [
          {
            "node": "Parse AI Validation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Validation": {
      "main": [
        [
          {
            "node": "Edit Fields - Validation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields - Validation": {
      "main": [
        [
          {
            "node": "Filter Only Thought Leadership",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Only Thought Leadership": {
      "main": [
        [
          {
            "node": "AI Extract Research Intelligence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Extract Research Intelligence": {
      "main": [
        [
          {
            "node": "Parse AI Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Response": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Log to Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log to Google Sheet": {
      "main": [
        [
          {
            "node": "Aggregate Weekly Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Weekly Summary": {
      "main": [
        [
          {
            "node": "Send Weekly Summary Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "905e2692-4112-4488-9a3e-105433b279e2",
  "meta": {
    "instanceId": "3a43da28588548e21903e71cf1dc3ddd65c24bf0c62e7e4b77542ffe87ad79c6"
  },
  "id": "aWcfVgPL4jkDAKpj",
  "tags": []
}